***Analysis for Paper titled Medical waste management in three areas of rural China
***Author Qiufeng Gao
use "/Users/gaoqiufeng/Dropbox/medical waste/Data/clean data/Medical waste management in three areas of rural China0508",clear
//Table1//

logout, save(Table1) word replace:tabstat thc_f_b_e_1 thc_f_b_e_2 fix_mil income_mil thc_f_b_b_9 num_patient_mon inpatient bed_rate,stats(mean sd min p25 p50 p75 max) c(s) f(%12.2fc)

//Appendix table 2//
logout, save(Appendix2_0) word replace:bysort province: tabstat thc_f_b_e_1 thc_f_b_e_2 fix_mil income_mil thc_f_b_b_9 num_patient_mon inpatient bed_rate,stats(mean sd) c(s) f(%12.2fc)

tokenize 1 2 3 4 5 6 7
foreach var of varlist thc_f_b_e_1 thc_f_b_e_2 fix_mil income_mil thc_f_b_b_9 num_patient_mon inpatient bed_rate{
logout, save(Appendix2_1_`1') word replace: anova `var' province 
macro shift
}

//Appendix table 2 cannot be generated directly

//Table2//
gen waste_bed_day=thc_f_totalkg1_day/thc_f_b_b_9 if thc_f_b_b_9!=. 
label var waste_bed_day "The amount of medical waste generated in the THC per bed per day (kg)"
gen patient_day=thc_f_b_b_3/365 
label var patient_day "Number of patients per day "
gen waste_patient_day=thc_f_totalkg1_day/patient_day
label var waste_patient_day "The amount of medical waste generated in the THC per patient per day (kg)"
gen patient_month=thc_f_b_b_3/12
gen person_day=(patient_month+thc_f_b_e_1)/30
sum person_day
gen waste_person_day=thc_f_totalkg1_day/person_day
sum waste_person_day
label var waste_person_day "The amount of medical waste generated in the THC per person per day(kg)"
logout, save(Table2) word replace:tabstat thc_f_totalkg1_day waste_bed_day waste_patient_day waste_person_day,stats(mean sd) c(s) f(%12.2fc)


//Appendix table3/
tokenize 1 2 3 4
foreach var of varlist thc_f_totalkg1_day waste_bed_day waste_patient_day waste_person_day{
logout, save(Appendix3_`1') word replace: tabstat `var' if  province==1,stats(mean sd) c(s) f(%12.2fc) 
logout, save(Appendix3_`1') word replace: tabstat `var' if  province==2,stats(mean sd) c(s) f(%12.2fc) 
logout, save(Appendix3_`1') word replace: tabstat `var' if  province==3,stats(mean sd) c(s) f(%12.2fc) 
logout, save(Appendix3_`1') word replace: anova `var' province 
macro shift
}

//Table3 
tokenize 1 2 3 4 5 6
foreach var of varlist thc_f_b_g_2 thc_f_b_g_1 thc_f_b_i_7 thc_f_b_i_8 thc_f_b_i_10 thc_f_b_i_11{
logout, save(Table3_`1') word replace:tab `var' 
macro shift
}
//The table3 can not be generated directly


//Table4

tokenize A B C D E F G H I J K
foreach var1 of varlist  thc_f_b_h1A  thc_f_b_h1B  thc_f_b_h1C  thc_f_b_h1D thc_f_b_h1E thc_f_b_h1F thc_f_b_h1G thc_f_b_h1H thc_f_b_h1I thc_f_b_h1J thc_f_b_h1K{
gen class_yes`1'=0
replace class_yes`1'=1 if `var1'=="1"
macro shift
} 
egen class_total=rowtotal(class_yesA-class_yesK)
label var class_total "Number of categories segerated into"
tab class_total,m

//logout//
tokenize 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
foreach var of varlist packaging seal signal thc_f_b_h1A thc_f_b_h1B thc_f_b_h1C thc_f_b_h1D thc_f_b_h1E thc_f_b_h1F class_total segerate_right burned burned_landfill landfill household_garbge sold{
logout, save(Table4_`1') word replace:tab `var' 
macro shift
}

//Table 5//
tab centralized_disposal
tab training_year
logout, save(Table5_`1') word replace:tab centralized_disposal
logout, save(Table5_`1') word replace:tab training_year

*END*

